<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>添加</title>
	<%@ include file="/WEB-INF/jsp/include.jsp"%>
	<script type="text/javascript">
        var path = "${path}";
        var params = new Object();
        $(function(){
		var taxCode = $("#taxCode").val();
            var period = $("#period").val();
            $.ajax({
                type:"POST",
                url:path+"/tdm/declareParameter/showledgerList?taxCode="+taxCode+'&period='+period,
//                data:params,
                dataType:"json",
                success:function callback(data){
                    var analyMsg = data.returnObject;
                    if (data.code=="0000") {
                        initGrid(analyMsg);
                    } else {
                        $.messager.alert('操作提示',data.msg,'info',function(){});
                    }
                }
            });
        });

        function initGrid(analyMsg) {

            $('#tt').treegrid({
                url : '',
                idField : 'dictCode',
                treeField : 'dictCode',
                toolbar : $('#tb'),
                columns : [ [ {
                    field: "dictCode", title: "id", align: "left",sortable: false,hidden:true, resizable: true, width: 80
                }, {
                    field: "dictName", title: "台账类别", align: "left", sortable: false, resizable: true, width: 200
                }
                ] ],
                onDblClickRow:function(row){

                    var returnValue = new Object();
                    returnValue.dictCode = row.dictCode;
                    returnValue.dictName = row.dictName;
                    parent.window.callback_selectLedger(returnValue);
                    closeLayer();
                    
                }
            });
            $("#tt").treegrid('loadData', analyMsg);
            $("#tt").treegrid('collapseAll');
            if(analyMsg.length>0){
                $('#tt').treegrid('select',analyMsg[0].dictCode);
			}

        }
        function closeBtn() {
            var row = $('#tt').treegrid('getSelected');
            if(row!=null){
                var returnValue = new Object();
                returnValue.dictCode = row.dictCode;
                returnValue.dictName = row.dictName;
                parent.window.callback_selectLedger(returnValue);
			}
			closeLayer();
            
      
        }
        function submit_Add() {
            var row = $('#tt').treegrid('getSelected');
            var returnValue = new Object();
            returnValue.dictCode = row.dictCode;
            returnValue.dictName = row.dictName;
            parent.window.callback_selectLedger(returnValue);
            closeLayer();
        }
        
//var node = $('#tt').treegrid('getSelected');
	</script>
</head>
<body  style="margin:0px; padding:0px;" >
<%@ include file="/WEB-INF/jsp/loading.jsp" %>
<div class="easyui-layout" fit="true" >
	
	<input type="hidden" id="taxCode" name="taxCode" value=${taxCode}>
	<input type="hidden" id="period" name="period" value=${period}>
	<div region="center" title="" border="false" noheader="true"
		 style="padding: 5px 0 0 0;overflow-y:hidden;">
		<table id="tt" title="" border="false"></table>
	</div>
	<div data-options="region:'south',title:'',split:false,border: false" style="height:55px;">
		<div align="center" style="margin-top: 15px;">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="submit_Add()">确定</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="closeBtn();">取消</a>
		</div>
	</div>
</div>

</body>
</html>
